<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>待发货订单</title>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
<body>
    <div style="margin: 20px">
        <form class="layui-form-item">
            <input type="hidden" id="orderId" th:value="${m.id}">
            <div class="layui-form-item">
                <label class="layui-form-label">金额数目</label>
                <div class="layui-input-block">
                    <input class="layui-input" type="text" readonly name="actuallyPaid" th:value="${m.actuallyPaid}" autocomplete="off" />
                </div>
            </div>
        </form>
    </div>
    <div class="layui-form-item" style="display: none;">
        <div class="layui-input-block">
            <a class="layui-btn" lay-submit="" lay-filter="submitBtn" id="submitBtn">提交</a>
            <a class="layui-btn" data-method="cancelBtn" id="cancelBtn">取消</a>
        </div>
    </div>

<script>
    var $;
    layui.use(['table','form','layer','jquery'],function() {
        var table = layui.table,
            form = layui.form,
            layer = layui.layer;
        $ = layui.jquery;

        var orderId = $('#orderId').val();


        var active = {
            dialog:function (data) {
                var actuallyPaid = $('#actuallyPaid').val();
                var dataForm = data.field;
                dataForm.actuallyPaid = actuallyPaid;
                $.ajax({
                    type:'post',
                    url:'/cc/order/addOne',
                    data:dataForm,
                    dataType:'json',
                    success:function(result){
                        active.paid(orderId,result);
                    }
                })
            },
            paid:function (id,cid) {
                $.ajax({
                    type:'post',
                    url:'/order/oc/update',
                    data:{
                        id: id,
                        status: 1,
                        courier: cid
                    },
                    dataType: 'json',
                    success:function (result) {
                        layer.msg(result.msg);
                        let index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);//关闭父页面窗口
                    }
                })
            }
        }

        form.on('submit(submitBtn)',function(data){
            active.dialog(data);
        })
    });

    function btnSubmit(){
        $('#submitBtn').click();
    }
    function btnCancel() {
        $('#cancelBtn').click();

    }
</script>

</body>
</html>